<?php
/**
 * 正式运营环境请关闭错误信息
 * ini_set("error_reporting", E_ALL);
 * ini_set("display_errors", TRUE);
 * DEBUG = TRUE  开启错误提示
 * DEBUG = FALSE 禁止错误提示
 * 默认禁止错误信息
 */
define("DEBUG", FALSE);
if (defined("DEBUG") && DEBUG)
{
    @ini_set("error_reporting", E_ALL);
    @ini_set("display_errors", TRUE);
}else{
    @ini_set("error_reporting", E_ERROR| E_PARSE | E_CORE_ERROR);
}

define('SERVER_TIME',           time());
define('SERVER_DATE_TIME',      date('Y-m-d H:i:s', SERVER_TIME));
define('WEB_DOMAIN_NAME',       '');
define('STATIC_DOMAIN_NAME',    '');
define('MALL_VERSION',    1);
define('ACCOUNT_LOG',    true);
define('SERVICE_MAIL_ADDR', 'service@ffrj.net');
if (!defined('WEB_SERVER_ROOT_PATH'))
{
    define('WEB_SERVER_ROOT_PATH',  dirname(__FILE__). '/../');
}
if (!defined('API_VERSION'))
{
    define('API_VERSION',   1);
}
# define('WEB_SERVER_ROOT_PATH',  '/opt/www/');

$_G = array();
require(WEB_SERVER_ROOT_PATH. 'config/TableMap.php');
require(WEB_SERVER_ROOT_PATH. 'config/ExpLevel.php');
require(WEB_SERVER_ROOT_PATH. 'config/Tags.php');
require(WEB_SERVER_ROOT_PATH. 'config/Emotion.php');
require(WEB_SERVER_ROOT_PATH. 'config/Category.php');
require(WEB_SERVER_ROOT_PATH. 'config/WeakPassword.php');
require(WEB_SERVER_ROOT_PATH. 'config/Cache.config.php');
require(WEB_SERVER_ROOT_PATH. 'config/ChatFilter.php');
require(WEB_SERVER_ROOT_PATH. 'lib/DataOperation.lib.php');
require(WEB_SERVER_ROOT_PATH. 'lib/FileOperation.lib.php');
require(WEB_SERVER_ROOT_PATH. 'lib/Storage.lib.php');
require(WEB_SERVER_ROOT_PATH. 'lib/UK.lib.php');
require(WEB_SERVER_ROOT_PATH. 'lib/MallSDK.lib.php');
require(WEB_SERVER_ROOT_PATH. 'lib/Gump.lib.php');
require(WEB_SERVER_ROOT_PATH. 'lib/push/Jpush.lib.php');

set_exception_handler(function ($e){});//兼容之前没有捕获异常的情况

class AppConfiguration
{
    const   CODE_DEBUG              =   DEBUG;
    const   API_VERSION             =   API_VERSION;
    const   SERVER_TIME             =   SERVER_TIME;
    const   SERVER_DATE_TIME        =   SERVER_DATE_TIME;
    const   WEB_SERVER_ROOT_PATH    =   WEB_SERVER_ROOT_PATH;
    const   WEB_DOMAIN_NAME         =   WEB_DOMAIN_NAME;
    const   STATIC_DOMAIN_NAME      =   STATIC_DOMAIN_NAME;
    const   DEFAULT_CACHE_TIME      =   86400;
    const   REGISTER_DEFAULT_STATUS =   0;
    const   RECORD_ACCOUNT_LOG      =   ACCOUNT_LOG;

    const   DIARY_LIST_DEFAULT_LEN  =   20;
    const   COMMENT_LIST_DISPLAY_LEN=   20;
    const   COMMENT_REPLY_LIST_LEN  =   5;
    const   FEED_LIST_DISPLAY_LEN   =   20;
    const   LIKE_LIST_DISPLAY_LEN   =   20;
    const   SHARE_LIST_DISPLAY_LEN  =   20;
    const   CLOUD_SYNC_DISPLAY_LEN  =   20;
    const   CHAT_LIST_DISPLAY_LEN   =   50;
    const   MESSAGE_BOX_DISPLAY_LEN =   20;

    const   FOLLOW_BASE_NUMBER      =   50;
    const   FOLLOW_STATUS_NORMAL    =   0;
    const   FOLLOW_STATUS_DELETE    =   1;
    const   FOLLOW_STATUS_BLACK     =   2;
    // abilityCondition
    const   ABILITY_AVATAR          =   1;
    const   ABILITY_FANS_LIMIT      =   50;
    const   ABILITY_DIARYS_LIMIT    =   50;
    const   ABILITY_LEVEL_LIMIT     =   12;
    const   ABILITY_TIME            =   604800;
    
    // 日记字数以及评论字数限制
    const   DIARY_DATA_NUMBERS          =   4092;
    const   DIARY_DATA_NUMBERS_ABILITY  =   20000;
    const   COMMECT_DATA_NUMBERS        =   2000;
   
    // 用户绑定
    const   ACCOUNT_TYPE_FENFEN_ACCOUNT  		=   1;
    const   ACCOUNT_TYPE_FENFEN_ID  		        =   2;
    const   ACCOUNT_TYPE_QQ 			=   10;
    const   ACCOUNT_TYPE_WEIBO	  		=   11;
    const   ACCOUNT_TYPE_WECHAT	  		=   12;
    const   ACCOUNT_TYPE_MOBILE  	=   3;

    const   OPEN_SYNC_SENDMSG_IM_STATUS = 0;//打开同步到im
    const   QUEUE_AMQ_STATUS = 1;//rabbitmq队列开关

    // 短信服务配置文件
    public static $smsApp = array(
        '粉粉日记' => array(
            'ext'   => '',
            'types' => array( 'mobile_register' => 1, 'mobile_bind' => 2, 'mobile_resetpasswd' => 3, 'mobile_signup' => 4, 'mobile_update' => 5)
        ),
        '可萌记账' => array(
            'ext'   => '1',
            'types' => array( 'mobile_register' => 11, 'mobile_bind' => 12, 'mobile_resetpasswd' => 13, 'mobile_signup' => 14, 'mobile_update' => 15 )
        ),
        '海豚记账' => array(
            'ext'   => '2',
            'types' => array( 'mobile_register' => 21, 'mobile_bind' => 22, 'mobile_resetpasswd' => 23, 'mobile_signup' => 24, 'mobile_update' => 25 )
        )
    );
    
    public static $accountTypeConfig = array(
        'fenfen'    =>  AC::ACCOUNT_TYPE_FENFEN_ACCOUNT,
        'mobile'    =>  AC::ACCOUNT_TYPE_MOBILE,
        'open_weibo'=>  AC::ACCOUNT_TYPE_WEIBO,
        'open_qq'   =>  AC::ACCOUNT_TYPE_QQ,
        'open_wechat'=>  AC::ACCOUNT_TYPE_WECHAT
    );
    
    public static $openTypes = array(
        'qq','weibo','wechat'
    );
    
    const   ADMIN_DISPLAY_LEN       =   50;
    const   FETCH_USER_LIST_LEN     =   50;

    const   HOST_UID                =   HOST_UID;
    const   MD5_KEY                 =   'xxtSNS';
    
    const   DIARY_TAG_MAXID  	    =   50;
    const   DIARY_TEXT_SIZE_MAXID   =   36;
    
    const   RECOMMENT_USER_LIST_LEN =   19;
    const   START_HOUR       	    =   23;
    const   END_HOUR	            =   8;
    
    const   CODENUMPERHOUR          =   5;
    const   CODENUMDAILY            =   8;
    const   CODEEXPIRE              =   1800;
    const   ONEMINUTE               =   60;
    const   ONEHOUR                 =   3600;
    const   ONEDAY                  =   86400;

    const   DIARYATTACHMENTLIMIT    =   60;
    const   DIARYVOICELIMIT         =   15;
    const   DIARYVIDEOLIMIT         =   5;
	const   DIARYLINKLIMIT          =   5;
    public static $topicDiaryAttachmentLimit   =   9;

    //文章附件数量
    const   ARTICLEATTACHMENTLIMIT    =   50;
    const   ARTICLEVOICELIMIT         =   1;
    const   ARTICLEVIDEOLIMIT         =   1;
    const   ARTICLELINKLIMIT          =   5;
    const   ARTICLECONTENTLENGTH      =   60000;
    const   ARTICLESUMMARYLENGTH      =   450;
    const   ARTICLETITLELENGTH        =   96;

    // 照片墙默认显示照片张数
    const   PHOTOS_LIST_DEFAULT_LEN  =   20;
    
    const   CHAT_GROUP_DISPLAY_LEN  =   20;
    const   CHAT_USERS_DISPLAY_LEN  =   50;
    const   CHAT_MESSAGE_DISPLAY_LEN=   20;
    const   USER_GROUP_MAX_NUM      =   10;
    const   VIP_GROUP_MAX_NUM       =   23;
    const   USER_GROUP_MAX_MEMBERS  =   30;
    const   VIP_GROUP_MAX_MEMBERS   =   100;
    const   CHAT_GROUP_LEVEL_LIMIT  =   15;
    
    const   CHAT_GROUP_AUTH_MEMBERS     =   20;
    const   CHAT_GROUP_AUTH_LEVEL       =   2;
    const   CHAT_GROUP_AUTH_ABILITIES   =   3;
    
    // 群组用户状态
    const   CHAT_GROUP_PASS_STATUS  =   1;
    const   CHAT_GROUP_IGNORE_STATUS=   2;
    const   CHAT_GROUP_APPLY_STATUS =   4;
    const   CHAT_GROUP_QUIT_STATUS  =   5;
    const   CHAT_GROUP_FIRE_STATUS  =   6;

    //建群数
    const   VIP_EXTRA_CREATE_GROUP_MAX_NUM  = 3;
    const   USER_CREATE_GROUP_MAX_NUM       = 1;
    const   USER_JOIN_GROUP_MAX_NUM =   10;
    const   VIP_JOIN_GROUP_MAX_NUM  =   20;

    //举报处理状态
    const   STATUS_REPORT_PENDING   =   0;
    const   STATUS_REPORT_PROCESSED =   1;

    // 聊天室配置
    const   CHAT_ROOM_MAX_P         =   10;
    const   CHAT_ROOM_PASS_STATUS   =   1;
    const   CHAT_ROOM_QUIT_STATUS   =   2;
    const   CHAT_ROOM_FIRE_STATUS   =   3;
    const   CHAT_ROOM_ROLE_COMMON   =   0;
    const   CHAT_ROOM_ROLE_CREATOR  =   1;
    const   DEFAULT_CHAT_ROOM_EXPIRE=   86400;

    //会员经验加成倍数
    const   VIP_EXP_ADDED_TIMES      = 1.2;
    const   VIP_YEAR_EXP_ADDED_TIMES = 1.5;

    //会员是否按照规则额外增加经验
    public static $allowVipExpAdded  = true;

    // 图片验证码开关
    const  CAPTCHA_SWITCH = false;
    // 是否测试数据库
    const  ENV_TEST = 0; //正式上线要改成 0 !!!! 正式上线要改成 0 !!!! 正式上线要改成 0 !!!!
    
    //圈子社群
    const   USER_JOIN_GROUP_NUM   =   100;
    const   USER_CREATE_GROUP_NUM =   2;
    const   USER_MANAGE_GROUP_NUM =   3;
    const   GROUP_CIRCLE_TYPE     =   1;
    const   GROUP_MANAGE_USER_NUM =   2;
    const   GROUP_TOP_TOPIC_NUM   =   3;

    //默认精选圈子及对应背景图
    public static $groupList = [16,7,4,5,10];
    public static $defaultImageList = [
        '16'    =>  'http://img.fenfenriji.com/4D/AF/54/Image/2DC0623F-778E-2CF0-516A-59CF08D05D15.jpg',
        '7'     =>  'http://img.fenfenriji.com/4D/AF/54/Image/CE2E9F24-D03F-E0D7-A860-59CF08D86D80.jpg',
        '4'     =>  'http://img.fenfenriji.com/4D/AF/54/Image/6A1BF5EA-728F-C31D-DAC0-59CF08248BD2.jpg',
        '5'     =>  'http://img.fenfenriji.com/4D/AF/54/Image/2BACC9D5-797B-DBE6-CC96-59CF087E1277.jpg',
        '10'    =>  'http://img.fenfenriji.com/4D/AF/54/Image/89787CF1-A260-838C-F556-59CF08174707.jpg',
    ];
    
    public static $errorNo          =   NULL;
    public static $errorMsg         =   '';
    public static $feedInfo         =   NULL;
    public static $profitInfo       =   NULL;
    public static $debugMessage     =   NULL;
    public static $itemStatistics   =   NULL;
    public static $userStatistics   =   NULL;
    public static $hostUserBaseInfo =   NULL;
    public static $appInfoList 	    =   NULL;
    public static $user             =   NULL;
    public static $meFollowUids     =   NULL;
    public static $gainCoin         =   NULL;
    public static $gainExp          =   NULL;
    
    public static $userVersion      =   0;
    public static $userVoiceVersion =   1;
    public static $topicFdVersion   =   1;
    public static $hotWidgetVersion =   1;
    public static $chatAttachmentVersion     =   1;
    public static $emotionShowVersion        =   1;
    public static $emotionTopicShowVersion   =   1;
    public static $closeBdMsgpushVersion     =   0;
    public static $openSendChatMsg2IMVersion =   0;
    public static $openApplyGroupVipVersion =   0;
    public static $paperIosDiaryShowVersion  =   1;
    public static $recommentByTagVersion     =   1;
    public static $shareSupportVersion       =   1;
    public static $retweetShareImgVersion    =   0;
    public static $iosFullVersion            =   0;
    public static $iosPlannerTagVersion		 =   0;	
    public static $plannerVersion            =   0;
    public static $femaleVersion             =   0;
    public static $skinPriviewVersion        =   0;
    public static $fixPasswdVersion          =   0;
    public static $recommendIosVersion       =   0;
    public static $subscriptionVersion       =   0;
    public static $anonymousCommentVerdion   =   0;
    public static $https_version             =   0;
    public static $video_version             =   0;
	public static $member                    =   0;
	public static $fontCoverVersion               =   0;
	public static $removeFollowVersion       =   0;
    public static $baidu_apiKey     = "qAneZ14WaxH1LsRvLadleD4K";
    public static $baidu_secretKey  = "Y90K5P39bKcnRqwt7o6P45ioU7ELMboL";
    public static $subscription_pic_number   = 0;
	public static $subscription_video_number = 0;
	public static $subscription_voice_number = 0;
	public static $articleHtmlAllowed        = "p,a[href],blockquote,ul,li,img[src|alt|data-width|data-height|data-action],
	span,span[data-color],h1,h2,h3,br,hr,video[src|poster|data-width|data-height|alt],audio[src|controls]";

	public static $attrArray = [
        'img'   => [
            'data-width'    =>  'Number',
            'data-height'   =>  'Number',
            'data-action'   =>  'Text',
        ],
        'span'  =>  [
            'data-color'    =>  'Text',
        ],
        'a'     =>  [
            'href'          =>  'Text'
        ],
    ];

	public static $elementArray = [
        [
            'name'      =>  'video',
            'type'      =>  'Block',
            'contents'   =>  'Flow',
            'attr_collections'  =>  [],
            'attributes'        =>  [
                'src'           =>  'Text',
                'poster'        =>  'Text',
                'data-width'    =>  'Number',
                'data-height'   =>  'Number',
                'alt'           =>  'Text',
            ],
        ],
        [
            'name'      =>  'audio',
            'type'      =>  'Block',
            'contents'   =>  'Flow',
            'attr_collections'  =>  [],
            'attributes'        =>  [
                'src'           =>  'Text',
                'controls'      =>  'Text'
            ],
        ],
    ];

    public static $userExpAction =   array(
    		"action"=>NULL,
    		"admin"=>FALSE,
    		"userid"=>0
    );
    
    public static $taskCondition       =   array(
        'type' =>  array('diary', 'topic', 'web', 'app'),
        'task' =>  array('share', 'youmi_vedio', 'ad', 'bmi')
    );
    
    public static $officialAccounts = array(
        'recommend'=> array(1, 2, 3, 4, 5, 6),
        'register' => array(2, 4, 6) // 21241456(8万)    21903430 5万 (09-02下)
    );
    
    public static $level_url_prefix =   "http://api.fenfenriji.com/info/group_level";
    public static $initGroupsStr    =   "16,4,1,5,6,7,10,12,17";
    public static $groupMaxGid      =   50;
    
    public static $openUrl    =    array(
            'user_login'            =>    'pinksns://user/login?',
            'user_signup'           =>    'pinksns://user/signup?',
            'user_account'          =>    'pinksns://user/account',
            'user_my'               =>    'pinksns://user/my?',
            'user_my_profile'       =>    'pinksns://user/my/profile',
            'user_my_tag'           =>    'pinksns://user/my/tag',
            'user_message'          =>    'pinksns://user/message?',
            'user_info'             =>    'pinksns://user/info?',
            'user_followers'        =>    'pinksns://user/followers?',
            'user_friends'          =>    'pinksns://user/friends?',
            
            'diary_info'            =>    'pinksns://diary/info?',
            'diary_post'            =>    'pinksns://diary/post?',
            
            'group_list_my'         =>    'pinksns://group/list/my',
            'group_list_all'        =>    'pinksns://group/list/all',
            'group_list_recommend'  =>    'pinksns://group/list/recommend',
            'group_info'            =>    'pinksns://group/info?',
            'group_topic'           =>    'pinksns://group/topic?',
            'group_mytopic'         =>    'pinksns://group/mytopic',
            'group_commentme'       =>    'pinksns://group/commentme',
            
            'groupchat_mygroup'     =>    'pinksns://groupchat/mygroup',
            'groupchat_create'      =>    'pinksns://groupchat/create',
            'groupchat_message'     =>    'pinksns://groupchat/message',
            'groupchat_detail?'     =>    'pinksns://groupchat/detail?',
            'groupchat_chat'        =>    'pinksns://groupchat/chat?',
            'groupchat_detail_users'=>    'pinksns://groupchat/detail/users?',
            
            'channel_search'        =>    'pinksns://channel/search?',
            'channel_timeline'      =>    'pinksns://channel/timeline',
            'channel_diaryhot'      =>    'pinksns://channel/diaryhot',
            'channel_diarycategory' =>    'pinksns://channel/diarycategory?',
            'channel_recommenduser' =>    'pinksns://channel/recommenduser',
            'channel_chatroom'      =>    'pinksns://channel/chatroom',
            'channel_top'           =>    'pinksns://channel/top',
            'channel_ability'       =>    'pinksns://channel/ability',
            'channel_boyi'          =>    'pinksns://channel/biz/boyiqove?',
            
            'channel_webview'       =>    'pinksns://channel/webview?',
            
            'mall_paper'            =>    'pinksns://mall/paper',
            'mall_paper_detail'     =>    'pinksns://mall/paper/detail?',
            'mall_emotion'          =>    'pinksns://mall/emotion',
            'mall_emotion/detail'   =>    'pinksns://mall/emotion/detail?',
        
            'duiba'                 =>    'pinksns://channel/biz/duiba/redirect?',

            'article_info'          =>    'pinksns://article/info?',
    );
    
    # 1.0.1于2014.10.23创建
    public static $antispam_version =   "1.0.1";
    
    private static $processDbKeyCache;
    private static $processMcKeyCache;
    const   MEMCACHE_SWITCH         =   TRUE;
    
    #redis
    const   REDIS_READ              =   TRUE;
    const   REDIS_WRITE             =   TRUE;
    
    const   USE_MYSQL_SLAVE         =   TRUE;
    # 推送方式选择
    const   PUSH_TO_REDIS           =   TRUE;
    
    # Feed type & map class /*{{{*/
    const   FEED_DIARY              =   1;
    const   FEED_FOLLOW             =   16;
    const   FEED_COMMENT            =   17;
    const   FEED_LIKE               =   18;
    const   FEED_SHARE              =   19;
    const   FEED_KIT_ANNIVERSARY    =   12;
    const   FEED_KIT_BMI            =   14;
    const   FEED_KIT_MENSES         =   15;
    const   FEED_KIT_NOTE           =   9;
    const   FEED_KIT_SCHEDULE       =   10;
    const   FEED_KIT_TALLYBOOK      =   8;
    const   FEED_REPOST             =   21;
    const   FEED_ANNOUNCE           =	24;//全站公告
	const   FEED_REMOVEFOLLOW       =   25;//取消关注

    #articleType
    const   ARTICLE_ATTACHMENT_TYPE     =    4;
    const   ARTICLE_COMMENT_ATTACHMENT_TYPE     =    6;
    const   COMMENT_ATTACHMENT_TYPE     =    5;
    const   ARTICLE_BODY_TYPE           = 11;
    const   TAG_TYPE_ARTICLE           = 1;

    #recommend
    const   RECOMMEND_TYPE_DIARY   =    0;          //点滴
    const   RECOMMEND_CATEGORY_HOT_DIARY   =    1;  //话题下的热门点滴

    # group
    const	VIP_MAX_MEMBER_NUM		=	100;
    const	COM_MAX_MEMBER_NUM		=	50;
    const	COM_MAX_GROUP_NUM		=	1;
    const	VIP_MAX_GROUP_NUM		=	2;
    const	GROUP_CREATE_LEVEL		=	6;
    const	GROUP_NAME_LENGTH		=	20;
    const	GROUP_INTRO_LENGTH		=	400;
    const	GROUP_MEMBERS_DISPLAY_LEN       =       20;
    const	TOPIC_TITLE_LENGTH		=	120;
    const	TOPIC_BODY_LENGTH		=	15000;
    const	TOPIC_LIST_DISPLAY_LEN	        =	20;
    const	GROUP_LIST_DISPLAY_LEN	        =	20;
    const       TOPIC_ABBRE_LENGTH		=	200;
    const	STICK_TOPIC_NUMS    	        =	3;
    const       GROUP_UPPER_LIMIT               =	15;
    const       FOLLOW_TOPIC_UPPER_LIMIT               =	15;
    const	RECOMMENT_TOPIC_LIST_LEN 	=   	20;
    
    # shop
    const       SHOP_DEFAULT_DISPLAY_LENGTH     =	20;
    const      	EMOTION_MATCHRETURN_NUMBER      =	50;
    const       SHOP_EMOTION_DISPLAY_LENGTH     =	50;
    const       SHOP_PAPER_DISPLAY_LENGTH       =	50;
    const       PLANNER_LENGTH			=	500;
    
    # LBS
    const       LBS_TYPE_USER  =1;
    const       LBS_TYPE_DIARY =2;
    const       LBS_TYPE_GROUP =3;
    
    # 官方群
    public static $officialGids        =   array(300000, 300001, 300002, 300003, 300004, 300005, 300006, 322710, 336137);
    public static $officialMemberNum   =   array(300000 => 500, 300001 => 500, 300002 => 500, 300003 => 500, 300004 => 500, 300005 => 500, 300006 => 500, 322710 => 500,  336137 => 500);
    
    # 可申请认证状态
    public  static $femalApplyStatus = array(
        'no' => 0,
        'yes'   => 1
    );
    
    #女生认证上传的录音或视频类型
    public  static $femalAuthUploadType = array(
        'music' => 1,
        'video' => 2 
    );
    
    #   女生认证
    public static $femaleAuthStatus   =   array(
        'success'       =>  0,
        'apply'	        =>	1,
        'fail' 	        =>  2,
        'default'       =>  3,
        'again_apply'   =>  4
    );

    public static $anonymousOpenTime = [
        'start' => 72000, //当天00之后的秒数, 20:00
        'end'   => 86400,//24:00
        'not_allow_string' => '匿名开放时间为20:00 - 24:00'
    ];

    public static $flashChatOpenTime = [
        'start' => 72000, //当天00之后的秒数, 20:00
        'end'   => 79200, //24:00
        'not_allow_string' => '闪聊星球开放时间为20:00 - 22:00'
    ];

    #性别
    public static $sex = array(
    	'girl' 		  => 0,
    	'boy'  		  => 1,
    	'secret'	  => 2,
    	'femaleauth'  => 3
    );

    # 计数加权类别
    public static $count_weight_type = array(
        'topic'     => 1,
        'diary'     => 2,
        'comment'   => 3
    );
    
    # API form表单
    public static $upyunBucket   =   array(
    		'xxt-pink-photo'            =>  'pKkivj2AX7DTtmAnzIhiQoYvok4=',
    		'xxt-pink-photo-pri' 	    =>  'p6QXTcgGlLa0BNraTJwLyaQ+xz8=',
    		'xxt-pink-audio-pri'	    =>	'zs7jIh5/oTh6VZJZyVgAVPUlsHc=',
    		'xxt-pink-audio'            =>  'SCeIcuQjwr5qWAuRRJz+s4tuTM4='
    );
    
    # 兑吧
    public static $duibaAutoLoginUrl = 'https://www.duiba.com.cn/autoLogin/autologin?';
    public static $duibaAppKey       = "2aA3Nbsq9JW94roiNVt38rV2VNRG";
    public static $duibaAppSecret    = "3gFCA2QGUb6BozNKL1a6SyKqx7gy";

    //CDN地址
    public static $cdn_url_d = 'https://d.fenfenriji.com';
    public static $cdn_url_img = 'https://img.fenfenriji.com';
    public static $cdn_url_icon = 'https://icon.fenfenriji.com';
    public static $cdn_url_media = 'https://media.fenfenriji.com';

    //表情云 https
    public static $cdn_url_biaoqingyun = 'https://dn-bqmm.qbox.me';

    const  LIMITLENGTHOFLIST = 2000;

    # 点滴评论
    const   NICKNAMELENGTH      = 48;
    const   IMGATTACHMENTTYPE   = 1;
    const   VOICEATTACHMENTTYPE = 2;
    public  static $diaryCommentCf = array(
        'transfer_time'   =>  1453881600,
        'content_limit'   =>  2000,
        'diary_topicid'   =>  100,
        'article'         =>  1000
    );
    
    # 圈子话题评论类型、点滴评论类型
    const COMMENTOFGROUPTOPIOC = 0;
    const COMMENTOFTOPICDIARY  = 1;

    #楼中楼版评论类别
    const COMMENT_TYPE_DIARY = 1;
    const COMMENT_TYPE_GROUP = 2;

    # 点滴话题
    public static $diaryTopicCf = array(
        'start_id'      =>  10000,
        'pass_status'   =>  1,
        'review_status' =>  2,
        'delete_status' =>  3,
        'common'        =>  0,
        'official'      =>  1,
        'diary_topic'   =>  1,
        'name_limit'    =>  24
    );
    
    public static $accountActions = array(
        "register"      =>"注册",
        "login"         =>"登陆",
        "modifypasswd"  =>"修改登陆密码",
        "accountbind"   =>"账号绑定",
        "accountunbind" =>"账号解绑"
    );

    //订阅号作者类型
    public static $subAuthorType = array(
        1  => "独家",
        2  => "非独家"
    );
    
    #验证码host
    public static $captchaHost = 'http://captcha.service.fenfenriji.com/';
    
    // cnd域名
    public static $hostOfFenFen = array(
        'media' => 'http://media.fenfenriji.com'
    );

    public static $bodyidTypeCode   =   array(
                                            self::FEED_DIARY            =>  'DL',
                                            self::FEED_KIT_ANNIVERSARY  =>  'KAL',
                                            self::FEED_KIT_BMI          =>  'KBL',
                                            self::FEED_KIT_MENSES       =>  'KML',
                                            self::FEED_KIT_NOTE         =>  'KNL',
                                            self::FEED_KIT_SCHEDULE     =>  'KSL',
                                            self::FEED_KIT_TALLYBOOK    =>  'KTL',
                                        );
    public static $bodyidTypeClass  =   array(
                                            self::FEED_DIARY            =>  'diary',
                                            self::FEED_KIT_ANNIVERSARY  =>  'kit',
                                            self::FEED_KIT_BMI          =>  'kit',
                                            self::FEED_KIT_MENSES       =>  'kit',
                                            self::FEED_KIT_NOTE         =>  'kit',
                                            self::FEED_KIT_SCHEDULE     =>  'kit',
                                            self::FEED_KIT_TALLYBOOK    =>  'kit',
                                        );
    /*}}}*/

    public static function getDbClient($key)/*{{{*/
    {
        if (!empty(self::$processDbKeyCache[$key]))
        {
            return  self::$processDbKeyCache[$key];
        }
        $slave = false;
        $keysSlave = $key;
        if (substr($keysSlave,-6) == '/slave'){
            $slave = true;
            $keysSlave = substr($keysSlave,0,strlen($keysSlave)-6);
        }
        $splitKey       =   UK::splitMapKey($keysSlave);
        if (!isset($splitKey[1]))   return  NULL;

        $dbName         =   TableMap::$keyMapDbConfig[$splitKey[0]];
        if (empty($dbName)) return  NULL;

        $tablePrefix    =   TableMap::$keyMapTable[$splitKey[0]];
        $mulitTableIndex=   $tablePrefix. 'Index';
        $clientList     =   TableMap::$mulitTableIndex();

        $tableNumber    =   strlen($clientList);
        $tableSuffix    =   UK::getHashId($splitKey[1], $tableNumber, $splitKey[0]);
        $tableName      =   $tablePrefix. '_'. $tableSuffix;
        $clientServer   =   $clientList[$tableSuffix];

        $db['mapPrefix']    =   $splitKey[0];
        $db['tableSuffix']  =   $tableSuffix;
        $db['uuidName']     =   TableMap::$mapPrimaryKey[$splitKey[0]];
        $db['uuidValue']    =   $splitKey[1];
        $db['dbName']       =   $dbName;
        $db['tableName']    =   $tableName;
        $db['clientServer'] =   $clientServer;
        
        if ($slave  && AC::USE_MYSQL_SLAVE) {
            $db['clientServer'] = 'F'.$db['clientServer'];
        }
        
        self::$processDbKeyCache[$key]  =   $db;
        return  $db;
    }/*}}}*/

    public static function getDbClientByClient($keyClient)/*{{{*/
    {
        if (!empty(self::$processDbKeyCache[$keyClient]))
        {
            return  self::$processDbKeyCache[$keyClient];
        }

        $splitKey       =   UK::splitMapKey($keyClient);
        if (!isset($splitKey[1]))   return  NULL;

        $dbName         =   TableMap::$keyMapDbConfig[$splitKey[0]];
        if (empty($dbName)) return  NULL;

        $tablePrefix    =   TableMap::$keyMapTable[$splitKey[0]];
        $mulitTableIndex=   $tablePrefix. 'Index';
        $clientList     =   TableMap::$mulitTableIndex();

        $tableNumber    =   strlen($clientList);
        $tableSuffix    =   $splitKey[1];
        $tableName      =   $tablePrefix. '_'. $tableSuffix;
        $clientServer   =   $clientList[$tableSuffix];

        $db['mapPrefix']    =   $splitKey[0];
        $db['dbName']       =   $dbName;
        $db['tableName']    =   $tableName;
        $db['clientServer'] =   $clientServer;

        self::$processDbKeyCache[$keyClient]  =   $db;
        return  $db;
    }/*}}}*/

    public static function getDbClientByBodyid($code, $bodyId, $uuidName ="bodyId" )/*{{{*/
    {
        if (empty($code) || empty($bodyId)) return  NULL;
        if (empty($uuidName))$uuidName = "bodyId";

        $bodyidInfo     =   UK::getItemidByBodyid($bodyId);
        if (empty($bodyidInfo['itemId']))   return  NULL;

        $dbName         =   TableMap::$keyMapDbConfig[$code];
        if (empty($dbName)) return  NULL;

        $tablePrefix    =   TableMap::$keyMapTable[$code];
        $mulitTableIndex=   $tablePrefix. 'Index';
        $clientList     =   TableMap::$mulitTableIndex();

        $tableNumber    =   strlen($clientList);
        if ($tableNumber<   $bodyidInfo['tableIndex'])  return  NULL;

        $tableSuffix    =   $bodyidInfo['tableIndex'];
        $tableName      =   $tablePrefix. '_'. $bodyidInfo['tableIndex'];
        $clientServer   =   $clientList[$tableSuffix];

        $db['mapPrefix']    =   $code;
        $db['tableSuffix']  =   $bodyidInfo['tableIndex'];
        $db['uuidName']     =   $uuidName;
        $db['uuidValue']    =   $bodyId;
        $db['dbName']       =   $dbName;
        $db['tableName']    =   $tableName;
        $db['clientServer'] =   $clientServer;

        return  $db;
    }/*}}}*/

    public static function getMcClient($key)
    {
        return  'NoCache';
    }

    public static function getRedisClient($key)
    {
        return  RedisPool::get($key);
    }

    //根据系统选择相应协议
    public static function getProtocolUriByOS($uri){
        $os = UK::checkOS(self::$appInfoList[2]);
        if ($os=='2' && !self::$https_version){
            return str_replace('https://', 'http://', $uri);
        }
        switch ($os){
            case '2':$uri = str_replace('http://', 'https://', $uri);break;//ios
            case '1':$uri = str_replace('https://', 'http://', $uri);break;//android
        }
        return $uri;
    }
}

final class AC extends AppConfiguration{}

function __autoload($className)/*{{{*/
{
    $fileNamePath   =   AC::WEB_SERVER_ROOT_PATH;

    if ('Controller'==  substr($className, -10))
    {
        $fileName   =   $fileNamePath. 'controller/'. $className. '.class.php';
    }
    elseif('Model'  ==  substr($className, -5))
    {
        $fileName   =   $fileNamePath. 'model/'. $className. '.class.php';
    }
    elseif('Api'    ==  substr($className, -3))
    {
        $fileName   =   $fileNamePath. 'api/'. $className. '.class.php';
    }
    elseif('Service'    ==  substr($className, -7))
    {
        $fileName   =   $fileNamePath. 'service/'. $className. '.class.php';
    }
    else
    {
        $fileName   =   $fileNamePath. 'storage/'.$className. '.class.php';
    }
    require ($fileName);
}/*}}}*/

RedisPool::add_servers(array('FS1'=>array('10.161.163.63',6379)));
RedisPool::initGearmanClient();

include(WEB_SERVER_ROOT_PATH. 'config/local.config.php');
